#pragma once
#include "Hash.h"


template<class K, class V>
class unordered_map
{
	struct GetValueOfK
	{
		const K& operator()(const pair<K,V>& kv)
		{
			return kv.first;
		}
	};

public:
	typedef typename Hash<K, pair<K, V>, GetValueOfK>::Iterator iterator;
	typedef typename Hash<K, pair<K, V>, GetValueOfK>::Const_Iterator const_iterator;

	pair<iterator, bool> insert(const pair<K, V>& kv)
	{
		return _h.Insert(kv);
	}

	iterator find(const K& key)
	{
		return _h.Find(key);
	}

	V& operator[](const K& key)
	{
		auto it = _h.Find(key);
		return it._node->_data.second;
	}

	iterator begin()
	{
		return _h.Begin();
	}

	const_iterator begin() const
	{
		return _h.Begin();
	}

	iterator end()
	{
		return _h.End();
	}

	const_iterator end() const
	{
		return _h.End();
	}

private:
	Hash<K, pair<K,V>, GetValueOfK> _h;
};



